function findAllCard() {
	var lujing = getPath() + '/Card';

	//加载全部的银行卡信息
	$.ajax({
		type: 'post',
		url: lujing,
		async: true,
		dataType: 'json',
		data: {
			"method": "findAllCard",
			"cur": "1",
			"ps": "3",
		},
		success: function(jsonDate) {
			//console.log(jsonData);
			//console.log('++');
			var cardLists = jsonDate.cardLists;
			$(cardLists).each(function(index, data) {
				var cardId = data.id;
				//console.log(bankId);
				var cardName = data.cardName;
				var cardNumber = data.cardNumber;
				var cardChip = data.cardChip;
				var cardMoney = data.cardMoney;
				var cardHolder = data.cardHolder;
				var bankId = data.bankId;

				var checkboxtd = $('<td><input type="checkbox"  id="' + cardId + '"/></td>');
				var nametd = $('<td>' + cardName + '</td>');
				var numbertd = $('<td>' + cardNumber + '</td>');
				var chiptd = $('<td>' + cardChip + '</td>');
				var moneytd = $('<td>' + cardMoney + '</td>');
				var holdertd = $('<td>' + cardHolder + '</td>');
				var banktd = $('<td>' + bankId + '</td>');

				var tr = $('<tr class="bootstrap"></tr>');

				tr.append(checkboxtd);
				tr.append(nametd);
				tr.append(numbertd);
				tr.append(chiptd);
				tr.append(moneytd);
				tr.append(holdertd);
				tr.append(banktd);

				$('#tb').append(tr);
			});

		}
	});

	/*$.ajax({
		type: 'post',
		url: lujing,
		async: true,
		dataType: 'json',
		data: {
			"method": "findAllBank",
		},
		success: function(jsonDate) {
			//console.log(jsonDate.bankLists);
			var bankLists = jsonDate.bankLists;

			$(bankLists).each(function(index, data) {
				var bankId = data.id;
				var bankName = data.bankName;

				var bankOption = $('<option value="' + bankId + '">' + bankName + '</option>');
				$('#bankSelect').append(bankOption);
			})
		}
	});*/
}

$('#ad').click(findAllBank);

function findAllBank() {
	var lujing = getPath() + '/Card';
	$.ajax({
		type: 'post',
		url: lujing,
		async: true,
		dataType: 'json',
		data: {
			"method": "findAllBank",
		},
		success: function(jsonDate) {
			//console.log(jsonDate.bankLists);
			var bankLists = jsonDate.bankLists;

			$(bankLists).each(function(index, data) {
				var bankId = data.id;
				var bankName = data.bankName;

				var bankOption = $('<option value="' + bankId + '">' + bankName + '</option>');
				$('#bankSelect').append(bankOption);
			})
		}
	});
	$('#bankSelect').remove();
}

//添加
$('#addConfirm').click(function() {
	var lujing = getPath() + '/Card';

	var cardName = $('input[name="cardName1"]').val();
	var cardNumber = $('input[name="cardNumber1"]').val();
	var cardChip = $('input[name="cardChip1"]').val();
	var cardMoney = $('input[name="cardMoney1"]').val();
	var cardHolder = $('input[name="cardHolder1"]').val();
	var bankId = $('input[name="bankId1"]').val();

	$.ajax({
		type: 'post',
		url: lujing,
		async: true,
		dataType: 'json',
		data: {
			"method": "addCard",
			"cardName": cardName,
			"cardNumber": cardNumber,
			"cardChip": cardChip,
			"cardMoney": cardMoney,
			"cardHolder": cardHolder,
			"bankId": bankId,
		},
		success: function(jsonDate) {
			//console.log(jsonData);
			//var bankEntity=jsonDate.bankEntity;
			//console.log(bankEntity.bankName)
			$('tr.bootstrap').empty();
			findAllCard();
		}
	});
})

//修改1
$('#up').click(function() {
	var lujing = getPath() + '/Card';

	var updateId = $('input[type="checkbox"]:checked');
	//console.log(deleteId);
	/*var upStr='';
	updateId.each(function(index,data){
		upStr+=$(data).attr('id')+',';
	});
	upStr=upStr.substring(0,upStr.length-1);
	console.log(upStr);*/
	var upStr = updateId.attr('id');
	console.log(upStr);

	$.ajax({
		type: 'post',
		url: lujing,
		async: true,
		dataType: 'json',
		data: {
			"method": "updateCard",
			"upStr": upStr,
		},
		success: function(jsonData) {
			var cardEntity = jsonData.cardEntity;
			//console.log(bankEntity.bankName);
			var cardId = cardEntity.id;
			var cardName = cardEntity.cardName;
			var cardNumber = cardEntity.cardNumber;
			var cardChip = cardEntity.cardChip;
			var cardMoney = cardEntity.cardMoney;
			var cardHolder = cardEntity.cardHolder;
			var bankId = cardEntity.bankId;

			$('input[name="cardName2"]').attr('class', cardId);
			$('input[name="cardName2"]').val(cardName);
			$('input[name="cardNumber2"]').val(cardNumber);
			$('input[name="cardChip2"]').val(cardChip);
			$('input[name="cardMoney2"]').val(cardMoney);
			$('input[name="cardHolder2"]').val(cardHolder);
			$('input[name="bankId2"]').val(bankId);

		}

	});
})

//修改2
$('#upConfirm').click(function() {
	console.log('+++');
	var lujing = getPath() + '/Card';

	var cardId = $('input[name="cardName2"]').attr('class');
	var cardName = $('input[name="cardName2"]').val();
	var cardNumber = $('input[name="cardNumber2"]').val();
	var cardChip = $('input[name="cardChip2"]').val();
	var cardMoney = $('input[name="cardMoney2"]').val();
	var cardHolder = $('input[name="cardHolder2"]').val();
	var bankId = $('input[name="bankId2"]').val();

	$.ajax({
		type: 'post',
		url: lujing,
		async: true,
		dataType: 'json',
		data: {
			"method": "updateCard1",
			"cardId": cardId,
			"cardName": cardName,
			"cardNumber": cardNumber,
			"cardChip": cardChip,
			"cardMoney": cardMoney,
			"cardHolder": cardHolder,
			"bankId": bankId,
		},
		success: function(jsonDate) {
			console.log(jsonDate.result)
			//console.log(jsonData);
			//var bankEntity=jsonDate.bankEntity;
			//console.log(bankEntity.bankName)
			$('tr.bootstrap').empty();
			findAllCard();
		}
	});
})

$('#del').click(function() {
	var lujing = getPath() + '/Card';

	var deleteId = $('input[type="checkbox"]:checked');

	var delStr = deleteId.attr('id');
	//console.log(delStr);

	$.ajax({
		type: 'post',
		url: lujing,
		async: true,
		dataType: 'json',
		data: {
			"method": "deleteCard",
			"delStr": delStr,
		},
		success: function(jsonData) {
			$('tr.bootstrap').empty();
			findAllCard();

		}

	});
})